package wnhz.com.business.groupshop.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import wnhz.com.business.R;
import wnhz.com.business.groupshop.adapter.AllCommentAdapter;
import wnhz.com.business.base.BaseActivity;
import wnhz.com.business.groupshop.bean.AllCommentBean;
import wnhz.com.business.impl.ActionBarClickListener;
import wnhz.com.business.view.TranslucentActionBar;
import wnhz.com.business.view.pull.PullLoadMoreRecyclerView;

/**
 * 全部评论
 */
public class AllCommentActivity extends BaseActivity implements ActionBarClickListener, View.OnClickListener {

    @BindView(R.id.actionbar)
    TranslucentActionBar actionbar;
    @BindView(R.id.recycler_View)
    PullLoadMoreRecyclerView recyclerView;

    private AllCommentAdapter adapter;

    private String[] mUrls = new String[]{
            "http://d.hiphotos.baidu.com/image/h%3D200/sign=201258cbcd80653864eaa313a7dca115/ca1349540923dd54e54f7aedd609b3de9c824873.jpg",
            "http://d.hiphotos.baidu.com/image/h%3D200/sign=ea218b2c5566d01661199928a729d498/a08b87d6277f9e2fd4f215e91830e924b999f308.jpg",
            "http://img4.imgtn.bdimg.com/it/u=3445377427,2645691367&fm=21&gp=0.jpg",
            "http://img4.imgtn.bdimg.com/it/u=2644422079,4250545639&fm=21&gp=0.jpg",
            "http://img5.imgtn.bdimg.com/it/u=1444023808,3753293381&fm=21&gp=0.jpg",
            "http://img4.imgtn.bdimg.com/it/u=882039601,2636712663&fm=21&gp=0.jpg",
            "http://img4.imgtn.bdimg.com/it/u=4119861953,350096499&fm=21&gp=0.jpg",
            "http://img5.imgtn.bdimg.com/it/u=2437456944,1135705439&fm=21&gp=0.jpg",
            "http://img2.imgtn.bdimg.com/it/u=3251359643,4211266111&fm=21&gp=0.jpg",
            "http://img4.duitang.com/uploads/item/201506/11/20150611000809_yFe5Z.jpeg",
            "http://img5.imgtn.bdimg.com/it/u=1717647885,4193212272&fm=21&gp=0.jpg",
            "http://img5.imgtn.bdimg.com/it/u=2024625579,507531332&fm=21&gp=0.jpg"};

    private String goodsId;

    private List<AllCommentBean.InfoBean.UserTalkBean> userTalkBeenList = new ArrayList<>();
    private List<String> url = new ArrayList<>();

    public static Intent createIntent(Context context, String goodsId,String type) {
        Intent intent = new Intent(context, AllCommentActivity.class);
        intent.putExtra("goodsId", goodsId);
        intent.putExtra("type", type);
        return intent;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_all_comment);
        ButterKnife.bind(this);
        goodsId = getIntent().getStringExtra("goodsId");
        actionbar.setData("全部评论", R.drawable.ic_lefft_white, null, 0, null, 0, this);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            actionbar.setStatusBarHeight(getStatusBarHeight());
        }

        initData();
        initView();
    }

    private void initData() {
        url.add("http://img4.imgtn.bdimg.com/it/u=882039601,2636712663&fm=21&gp=0.jpg");
        url.add("http://img4.imgtn.bdimg.com/it/u=4119861953,350096499&fm=21&gp=0.jpg");
        url.add("http://img5.imgtn.bdimg.com/it/u=2437456944,1135705439&fm=21&gp=0.jpg");
        AllCommentBean.InfoBean.UserTalkBean userTalkBean = new AllCommentBean.InfoBean.UserTalkBean();
        userTalkBean.setUrl(url);
        userTalkBean.setImg("http://img5.imgtn.bdimg.com/it/u=2024625579,507531332&fm=21&gp=0.jpg");
        userTalkBeenList.add(userTalkBean);

    }

    private void initView() {
        recyclerView.setLinearLayout();
        adapter = new AllCommentAdapter(AllCommentActivity.this, userTalkBeenList);
        recyclerView.setAdapter(adapter);
//        UpF3HomeData(0);
        recyclerView.setOnPullLoadMoreListener(new PullLoadMoreRecyclerView.PullLoadMoreListener() {

            @Override
            public void onRefresh() {
//                UpF3HomeData(0);
                Toast.makeText(AllCommentActivity.this, "刷新", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onLoadMore() {
//                UpF3HomeData(1);
            }
        });
    }

    @Override
    public void onClick(View v) {

    }

    @Override
    public void onLeftClick() {
        finish();
    }

    @Override
    public void onRightClick() {

    }

    @Override
    public void onEditTextClick() {

    }
}
